home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_weap_ailasermophia.cog < prev    next >
Text File  |  1999-11-15  |  9KB  |  317 lines

  1. # Jones 3D Cog Script
  2. #
  3. # weap_AILaserMophia.cog
  4. #
  5. # Weapon Class Cog for Mophia Laser eyes.
  6. #
  7. # ### Programming Note ###
  8. # This cog relies on the fact that there is only one Mophia at a time
  9. # because it stores THING refs.
  10. #
  11. # [MDR]
  12. #
  13. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  14. #
  15. # ===================================================================
  16.  
  17. symbols
  18.  
  19. message        startup
  20. message        fire
  21. message        touched
  22. message        removed
  23. message        user0
  24.  
  25. # ************************** JUMP LABELS ************************
  26. flex    CreateImpactGlow                                local
  27. flex    SetVFXParams                                    local
  28. flex    MakeEyesFlash                                    local
  29.  
  30. # ************************* TEMPLATES ***************************
  31. template    tpl_laserGlow=purpleflash                    local
  32. template    tpl_blastGlow=mophiaBlast                    local
  33. material    mat_beam=gen_a4sfx_rbbeam_p.mat                local
  34.  
  35. model        mdl_large=aet_sm.3do                        local
  36. model        mdl_med=aet_sm_70.3do                        local
  37. model        mdl_sml=aet_sm_45.3do                        local
  38. model        mdl_xsml=aet_sm_25.3do                        local
  39.  
  40. # ************************* CUSTOM PARAMETERS *******************
  41. vector        vec_glowStartSize                            local
  42. vector        vec_glowEndSize                                local
  43. vector        vec_posEye                                    local
  44. flex        f_xyShift                                    local
  45. flex        f_zShift                                    local
  46. int            n_joint00                                    local
  47.  
  48. # ************************* WEAPON VARS *************************
  49. thing        t_glowLeft                                    local
  50. thing        t_glowRight                                    local
  51. thing        t_beamLeft                                    local
  52. thing        t_beamRight                                    local
  53.  
  54. thing        t_glowImpact                                local
  55. int            b_hitThing                                    local
  56.  
  57. # ************************* MISC LOCAL VARS *********************
  58. thing        t_mophia                                    local
  59. thing        t_victim                                    local
  60. thing        t_bullet                                    local
  61. int            n_MophiaSize                                local
  62. flex        f_beamSize                                    local
  63. flex        f_beamTime                                    local
  64. vector        vec_dir                                        local
  65. vector        vec_pos                                        local
  66. vector        vec_posLeft                                    local
  67. vector        vec_posRight                                local
  68.  
  69. end
  70.  
  71.  
  72. # ===================================================================
  73. code
  74.  
  75. # ...................................................................
  76. startup:
  77.  
  78.     b_hitThing = 0;
  79.  
  80.     return;
  81.  
  82.  
  83. # ...................................................................
  84. fire:
  85.  
  86.     t_mophia    = GetSourceRef();
  87.     t_bullet    = GetSenderRef();
  88.  
  89.     if ( t_bullet < 0 ) return;                                            # Bad bullet?  Bail...
  90.     SetThingUserData(t_bullet, 1);                                        # Mark bullet as "in flight"
  91.  
  92.     f_beamTime    = GetLifeleft(t_bullet);                                # Beam lifetime is lifetime of bullet
  93.     f_beamSize    = GetThingMoveSize(t_bullet);                            # Beam size is size of bullet
  94.  
  95.     t_glowLeft    = -1;
  96.     t_glowRight    = -1;
  97.     call MakeEyesFlash;
  98.  
  99.     if ( t_glowLeft > -1 )
  100.     {
  101.         t_beamleft        = CreatePolylineThing(t_bullet, t_glowLeft, '0 0 0', mat_beam, f_beamSize, f_beamSize, f_beamTime);
  102.         if ( t_beamleft > -1 )
  103.         {
  104.             CaptureThing(t_beamleft);
  105.             AttachThingToThingEx(t_beamleft, t_bullet, 0x08);
  106.         }
  107.     }
  108.  
  109.     if ( t_glowRight > -1 )
  110.     {
  111.         t_beamRight        = CreatePolylineThing(t_bullet, t_glowRight, '0 0 0', mat_beam, f_beamSize, f_beamSize, f_beamTime);
  112.         if ( t_beamRight > -1 )
  113.         {
  114.             CaptureThing(t_beamRight);
  115.             AttachThingToThingEx(t_beamRight, t_bullet, 0x08);
  116.         }
  117.     }
  118.  
  119.     if ( (t_glowLeft > -1) || (t_glowRight > -1) )
  120.     {
  121.         PlaySoundClass(t_bullet, 106);                                    # Play a SITHSOUNDCLASS_FIRE1 sound on bullet
  122.  
  123.         SetActorFlags(t_mophia, 0x40000);                                # Set IMMOBILE flag
  124.         #AISetCutsceneMode(t_mophia);
  125.         #AIDisableHeadTracking(t_mophia);
  126.     }
  127.  
  128.     return;
  129.  
  130.  
  131. # ...................................................................
  132. touched:
  133.  
  134.     t_victim = GetSourceRef();
  135.     t_bullet = GetSenderRef();
  136.     if ( (t_bullet < 0) || (GetThingType(t_bullet) != 3) )                # Check for SITH_THING_WEAPON
  137.         return;
  138.  
  139. #    DEBUGPRINT("Bullet touched");
  140.     SetThingUserData(t_bullet, 0);                                        # Mark bullet as "hit target"
  141.  
  142.     vec_pos = VectorSet( 0, 0, VectorZ(GetThingEyeOffset(t_victim))/2 );
  143.     vec_pos = VectorAdd(GetThingPos(t_victim), vec_pos);
  144.  
  145.     if ( t_beamleft > -1 )                                                # Attach beam to victim
  146.     {
  147.         SetThingPosEX(t_beamleft, vec_pos, GetThingSector(t_victim));
  148.         AttachThingToThingEx(t_beamleft, t_victim, 0x08);
  149.     }
  150.  
  151.     if ( t_beamRight > -1 )                                                # Attach beam to victim
  152.     {
  153.         SetThingPosEX(t_beamRight, vec_pos, GetThingSector(t_victim));
  154.         AttachThingToThingEx(t_beamRight, t_victim, 0x08);
  155.     }
  156.  
  157.     b_hitThing = 1;
  158.     call CreateImpactGlow;
  159.  
  160.     return;
  161.  
  162.  
  163. # ...................................................................
  164. removed:
  165.  
  166.     t_bullet = GetSenderRef();
  167.     if ( t_bullet < 0 )
  168.         return;
  169.  
  170. #    DEBUGFLEX(GetThingType(t_bullet), "Removing bullet or beam, type =");
  171.     if ( GetThingType(t_bullet) == 3 )                                    # Check for SITH_THING_WEAPON
  172.     {
  173.         if ( GetThingUserData(t_bullet) == 0 )                            # Bullet "hit target?"  Bail...
  174.             return;
  175.  
  176. #        DEBUGPRINT("Moving beams to final bullet pos");
  177.         if ( t_beamleft > -1 )                                            # Extend beams to final bullet pos
  178.             SetThingPosEX(t_beamleft, GetThingPos(t_bullet), GetThingSector(t_bullet));
  179.  
  180.         if ( t_beamRight > -1 )
  181.             SetThingPosEX(t_beamRight, GetThingPos(t_bullet), GetThingSector(t_bullet));
  182.  
  183.         call CreateImpactGlow;
  184.  
  185.         return;
  186.     }
  187.  
  188.     if ( GetThingType(t_bullet) == 14 )                                    # Check for SITH_THING_POLYLINE
  189.     {
  190.         ReleaseThing(t_beamleft);
  191.         ReleaseThing(t_beamRight);
  192.  
  193.         t_beamleft    = -1;
  194.         t_beamRight = -1;
  195.         t_glowLeft    = -1;
  196.         t_glowRight    = -1;
  197.  
  198.         ClearActorFlags(t_mophia, 0x40000);                            # Clear IMMOBILE flag
  199.         #AIEnableHeadTracking(t_mophia, GetLocalPlayerThing());
  200.         #AIClearCutsceneMode(t_mophia);
  201.     }
  202.  
  203.     return;
  204.  
  205.  
  206. # ...................................................................
  207. # Flash eyes
  208. # ...................................................................
  209. user0:
  210.  
  211.     t_mophia    = GetParam(0);
  212.     f_beamTime    = 0.4;
  213.  
  214.     PlaySoundClass(t_mophia, 125);                                        # play 'charge up' sound
  215.  
  216. # ...................................................................
  217. MakeEyesFlash:
  218.  
  219.     call SetVFXParams;
  220.  
  221.     t_glowLeft    = CreateThingAtPos(tpl_laserGlow, FindNewSectorFromThing(t_mophia, vec_posLeft), vec_posLeft, '0 0 0');
  222.     if ( t_glowLeft > -1 )
  223.     {
  224.         SetLifeLeft(t_glowLeft, f_beamTime);
  225.         AnimateSpriteSize(t_glowLeft, vec_glowStartSize, vec_glowEndSize, f_beamTime);
  226.     }
  227.  
  228.     t_glowRight    = CreateThingAtPos(tpl_laserGlow, FindNewSectorFromThing(t_mophia, vec_posRight), vec_posRight, '0 0 0');
  229.     if ( t_glowRight > -1 )
  230.     {
  231.         SetLifeLeft(t_glowRight, f_beamTime);
  232.         AnimateSpriteSize(t_glowRight, vec_glowStartSize, vec_glowEndSize, f_beamTime);
  233.     }
  234.  
  235.     return;
  236.  
  237.  
  238. # ===================================================================
  239. #    Subroutines
  240. # ===================================================================
  241.  
  242. # ...................................................................
  243. # t_bullet and possibly t_victim and vec_pos must be initialized!
  244. # ...................................................................
  245. CreateImpactGlow:
  246.  
  247.     if ( b_hitThing == 1 )
  248.     {
  249.         t_glowImpact = CreateThingAtPos(tpl_blastGlow, GetThingSector(t_victim), vec_pos, '0 0 0');
  250.     }
  251.     else
  252.     {
  253.         t_glowImpact = CreateThingAtPos(tpl_blastGlow, GetThingSector(t_bullet), GetThingPos(t_bullet), '0 0 0');
  254.     }
  255.  
  256.     if ( t_glowImpact > -1 )
  257.     {
  258.         if ( b_hitThing == 1 )
  259.         {
  260.             AttachThingToThingEx(t_glowImpact, t_victim, 0x08);
  261.         }
  262.     }
  263.  
  264.     b_hitThing = 0;
  265.  
  266.     return;
  267.  
  268.  
  269. # ...................................................................
  270. # t_mophia must be initialized
  271. # ...................................................................
  272. SetVFXParams:
  273.  
  274.     vec_pos        = GetThingJointPos(t_mophia, GetNodeByName(t_mophia, "smhead"));
  275.  
  276.     n_MophiaSize = GetThingModel(t_mophia);
  277.     if ( n_MophiaSize == mdl_large )
  278.     {
  279.         vec_glowStartSize    = VectorSet(0.25, 0.25, 0.4);
  280.         vec_glowEndSize        = VectorSet(0.40, 0.40, 0.7);
  281.         vec_posLeft            = VectorAdd(vec_pos, VectorTransformToOrient(t_mophia, '-0.012 0.058 0.0'));
  282.         vec_posRight        = VectorAdd(vec_pos, VectorTransformToOrient(t_mophia, '0.014 0.058 0.0'));
  283.         if ( !IsModePlaying(t_mophia, 66) )
  284.         {
  285.             vec_posLeft     = VectorSub(vec_posLeft, '0 0 0.068');
  286.             vec_posRight = VectorSub(vec_posRight, '0 0 0.068');
  287.         }
  288.     }
  289.     else if ( n_MophiaSize == mdl_med )
  290.     {
  291.         vec_glowStartSize    = VectorSet(0.20, 0.20, 0.4);
  292.         vec_glowEndSize        = VectorSet(0.35, 0.35, 0.7);
  293.         vec_posLeft            = VectorAdd(vec_pos, VectorTransformToOrient(t_mophia, '-0.010 0.042 0.0'));
  294.         vec_posRight        = VectorAdd(vec_pos, VectorTransformToOrient(t_mophia, '0.012 0.042 0.0'));
  295.     }
  296.     else if ( n_MophiaSize == mdl_sml )
  297.     {
  298.         vec_glowStartSize    = VectorSet(0.15, 0.15, 0.4);
  299.         vec_glowEndSize        = VectorSet(0.28, 0.28, 0.7);
  300.         vec_posLeft            = VectorAdd(vec_pos, VectorTransformToOrient(t_mophia, '-0.007 0.03 0.005'));
  301.         vec_posRight        = VectorAdd(vec_pos, VectorTransformToOrient(t_mophia, '0.008 0.03 0.005'));
  302.     }
  303.     else
  304.     {
  305.         vec_glowStartSize    = VectorSet(0.10, 0.10, 0.4);
  306.         vec_glowEndSize        = VectorSet(0.17, 0.17, 0.7);
  307.         vec_posLeft            = VectorAdd(vec_pos, VectorTransformToOrient(t_mophia, '-0.004 0.03 0.005'));
  308.         vec_posRight        = VectorAdd(vec_pos, VectorTransformToOrient(t_mophia, '0.005 0.03 0.005'));
  309.     }
  310.  
  311.     return;
  312.  
  313.  
  314.  
  315. # ===================================================================
  316. end
  317.